package org.example.controller;

import org.example.dao.entity.User;
import org.example.dao.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;
import java.util.UUID;


@RestController
public class UserController {
    @Autowired
    UserMapper userMapper;

    @GetMapping("/users")
    public List<User> doRegister() {
        return userMapper.getAllUsers();
    }
    @GetMapping("/insert")
    public void doInsert() {
        User user = new User();
        user.setId(new Random().nextLong());
        user.setName("xuxi");
        user.setEmail(UUID.randomUUID()+"@qq.com");
        user.setPassword("4567");
        user.setCreatedAt(System.currentTimeMillis());
        userMapper.insert(user);
    }

}
